#region Using Statements
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
#endregion

namespace MegaEngine.Source.Sprites
{
    class SideScrollingShip : Sprite
    {
        public float firingSpeed = .5f;
        public SideScrollingShip()
        {
            init();
            this.velocity = new Vector2(0.0f, 0.0f);
            this.color = Color.White;
            this.bounds.X = 360;
            this.bounds.Y = 240;
            this.bounds.Width = 30;
            this.bounds.Height = 6;
            this.numFrames = 2;
        }
        public override bool update(float xOrigin, float yOrigin, int width, int height, GameTime gameTime, ArrayList environment, Vector2 theOrigin)
        {
            animate(gameTime.TotalGameTime.Milliseconds);
            float xMax = xOrigin + width;
            float yMax = yOrigin + height;
            if (bounds.X > xMax - bounds.Width)
            {
                bounds.X = (int)(xMax - bounds.Width);
            }
            else if (bounds.X < xOrigin)
            {
                bounds.X = (int)(xOrigin);
            }

            if (bounds.Y < yOrigin)
            {
                bounds.Y = (int)(yOrigin);
            }
            else if (bounds.Y > yMax-bounds.Height)
            {
                bounds.Y = (int)(yMax - bounds.Height);
            }
            return true;
        }
        public override Rectangle getBounds()
        {
            return bounds;
        }
        public override void onCollission(Sprite other)
        {
            Console.WriteLine("COLLISSION!");

        }
        public override void input( )
        {
            KeyboardState keyboard = Keyboard.GetState();
            velocity.X = 0.0f;
            velocity.Y = 0.0f;
            keyboard = Keyboard.GetState();
            if (keyboard.IsKeyDown(Keys.Left))
            {
                velocity.X = -400.0f;
            }
            if (keyboard.IsKeyDown(Keys.Right))
            {
                velocity.X = 400.0f;
            }
            if (keyboard.IsKeyDown(Keys.Up))
            {
                velocity.Y = -400.0f;
            }
            if (keyboard.IsKeyDown(Keys.Down))
            {
                velocity.Y = 400.0f;
            }
        }

        public override void updateAnimationState()
        {
            throw new Exception("The method or operation is not implemented.");
        }
    }
}
